{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "9a5705fd",
   "metadata": {},
   "outputs": [],
   "source": [
    "import requests\n",
    "API_Key = \"vGlwjQJXYKWyXOELKQFxrFFQzD88d4Cx\"\n",
    "API_Secret = \"rKDegTysiZpO47UF-Y_-bMwxN8PygYEN\"\n",
    "base_url = \"https://api-cn.faceplusplus.com/facepp/v3/detect\"\n",
    "\n",
    "payload = {\n",
    "    \"api_key\":API_Key,\n",
    "    \"api_secret\":API_Secret,\n",
    "    \"image_url\":\"https://img2.baidu.com/it/u=1724334041,2478716263&fm=253&fmt=auto&app=138&f=PNG?w=651&h=500\",\n",
    "    \"return_attributes\":\"gender,age,smiling\"\n",
    "}\n",
    "\n",
    "r = requests.post(base_url,payload)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "99e09315",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Response [200]>"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "r"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "256d6617",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "b'{\"request_id\":\"1646664669,46d4322c-0905-41dc-b668-8212ecd8c566\",\"time_used\":293,\"faces\":[{\"face_token\":\"ecc20f279a33e5f9debb221a88ca523b\",\"face_rectangle\":{\"top\":140,\"left\":249,\"width\":168,\"height\":168},\"attributes\":{\"gender\":{\"value\":\"Male\"},\"age\":{\"value\":32},\"smile\":{\"value\":65.863,\"threshold\":50.000}}}],\"image_id\":\"5IbeL9J+aSods++8sryIbg==\",\"face_num\":1}\\n'"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "r.content"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "281db839",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'{\"request_id\":\"1646664669,46d4322c-0905-41dc-b668-8212ecd8c566\",\"time_used\":293,\"faces\":[{\"face_token\":\"ecc20f279a33e5f9debb221a88ca523b\",\"face_rectangle\":{\"top\":140,\"left\":249,\"width\":168,\"height\":168},\"attributes\":{\"gender\":{\"value\":\"Male\"},\"age\":{\"value\":32},\"smile\":{\"value\":65.863,\"threshold\":50.000}}}],\"image_id\":\"5IbeL9J+aSods++8sryIbg==\",\"face_num\":1}\\n'"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "r.text"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "1bd491c2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'request_id': '1646664669,46d4322c-0905-41dc-b668-8212ecd8c566',\n",
       " 'time_used': 293,\n",
       " 'faces': [{'face_token': 'ecc20f279a33e5f9debb221a88ca523b',\n",
       "   'face_rectangle': {'top': 140, 'left': 249, 'width': 168, 'height': 168},\n",
       "   'attributes': {'gender': {'value': 'Male'},\n",
       "    'age': {'value': 32},\n",
       "    'smile': {'value': 65.863, 'threshold': 50.0}}}],\n",
       " 'image_id': '5IbeL9J+aSods++8sryIbg==',\n",
       " 'face_num': 1}"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "r.json()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "541f73a8",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
